package io.xxx.mario.task;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.apache.ibatis.type.EnumOrdinalTypeHandler;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

@Data
@TableName(autoResultMap = true)
public class Task {

    @TableId
    private Long id;

    /**
     * 名称
     */
    private String name;

    @TableField(typeHandler = EnumOrdinalTypeHandler.class)
    private ExecutionMode executionMode;

    /**
     * 开始时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime startTime;

    /**
     * 发送范围
     */
    @TableField(typeHandler = EnumOrdinalTypeHandler.class)
    private ScopeType scopeType;

    @TableField(typeHandler = EnumOrdinalTypeHandler.class)
    private SelectMode selectMode;

    @TableField(typeHandler = JacksonTypeHandler.class)
    private Map<String, Object> selectContent;

    private Integer receiverCount;

    private int ipadScale;

    private int appScale;

    @TableField(typeHandler = EnumOrdinalTypeHandler.class)
    private ReceiverType receiverType;

    private boolean startNow;

    @TableField(typeHandler = EnumOrdinalTypeHandler.class)
    private TaskStatus status;

    /**
     * 推送进度
     */
    private Double process;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createdTime;

    private Long createdId;

    private String createdName;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updatedTime;

    private Long updatedId;

    private String updatedName;

    @TableField(exist = false)
    private List<TaskMessage> messages;

    @TableField(exist = false)
    private List<TaskRoom> rooms;
}
